﻿<UserControl x:Class="NexTrackDesktop.Controls.Playlist"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:media="clr-namespace:NexTrackDesktop.Media"
             xmlns:vm="clr-namespace:NexTrackDesktop.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="220">
    <UserControl.Resources>
        <vm:PlaylistViewModel x:Key="TestData">
            <vm:PlaylistViewModel.Songs>
                <vm:SongViewModel>
                    <vm:SongViewModel.Song>
                        <media:Song Album="FISHIES" Artist="DETHKLOK" Title="MurmaidMurmaidMurmaidMurmaidMurmaidMurmaid" Length="00:25:15.0"
                                    AlbumArtSource="https://www.google.com/images/srpr/logo4w.png"/>
                    </vm:SongViewModel.Song>
                </vm:SongViewModel>
            </vm:PlaylistViewModel.Songs>
        </vm:PlaylistViewModel>
    </UserControl.Resources>
    
    <Grid>
        <ListBox d:DataContext="{StaticResource TestData}" ItemsSource="{Binding Path=Songs}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="2" HorizontalAlignment="Stretch">
                        <Border Height="48" Width="48" HorizontalAlignment="Left" VerticalAlignment="Top"
                                BorderBrush="Black" BorderThickness="1" CornerRadius="3" Style="{StaticResource AlbumArtStyle}" />
                        
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Margin="55,2,34,2" FontSize="11"
                                   Text="{Binding Path=Song.Title}" />
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Right" Margin="2,2" FontSize="11" Width="Auto"
                                   Text="{Binding Path=Song.Length, StringFormat={}{0:mm':'ss}}" />
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="55,20,0,0"
                                   FontStyle="Italic" Foreground="#222" FontSize="9">
                            <TextBlock.ToolTip>
                                <TextBlock><Run Text="{Binding Path=Song.Album}"/> - <Run Text="{Binding Path=Song.Artist}"/></TextBlock>
                            </TextBlock.ToolTip>
                            <Run Text="{Binding Path=Song.Album}"/> - <Run Text="{Binding Path=Song.Artist}"/>
                        </TextBlock>

                        <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="16" Height="16"
                            Name="ForcePlay" Command="{Binding ForcePlaySong}" ToolTip="Force Play This Song">
                            <Button.Style>
                                <Style TargetType="Button">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Setter Property="BorderThickness" Value="1"/>
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                                    <Setter Property="Padding" Value="1"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Button}">
                                                <Grid x:Name="Chrome" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                </Grid>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsEnabled" Value="false">
                                                        <Setter Property="Foreground" Value="#ADADAD"/>
                                                        <Setter Property="Opacity" TargetName="Chrome" Value="0.5"/>
                                                    </Trigger>
                                                    <Trigger Property="IsMouseOver" Value="true">
                                                        <Setter Property="Opacity" TargetName="Chrome" Value="0.75"/>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Button.Style>

                            <Canvas Name="svg2" Width="32" Height="32" ClipToBounds="True"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                                <Canvas Name="backbord">
                                    <Rectangle RadiusX="0" RadiusY="0" Width="32" Height="32" Canvas.Left="0" Canvas.Top="0" />
                                </Canvas>
                                <Canvas Name="fast_x5F_forward">
                                    <Path Fill="#FF000000">
                                        <Path.Data>
                                            <PathGeometry FillRule="Nonzero" Figures="M0,28L12,15.999 0,4 0,28z M14,4L14,28 26,15.999 14,4z" />
                                        </Path.Data>
                                    </Path>
                                </Canvas>
                                
                                <Canvas.LayoutTransform>
                                    <ScaleTransform ScaleX="0.5" ScaleY="0.5" />
                                </Canvas.LayoutTransform>
                            </Canvas>

                        </Button>

                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
        
    </Grid>
</UserControl>
